<?php
class Propriete{
	private $id;
	private $infos;
	private $is_default;
	private $typeEntiteId;
	private $TypePropriete;
	private $Liste;
	private $values;
	function __construct($id) {

		if (is_int($id)){
			if($id >= 0){
				$this->id=$id;
			}else{
				throw new FieldFormatException($_SESSION['translator']->idVal);
			}
		}else{
			throw new FieldFormatException($_SESSION['translator']->idInt);
		}
	}
	public function getId(){
		return $this->id;
	}
	public function getInfos(){
		return $this->infos;
	}
	public function getInfo($iso){
		$val =null;
		foreach ($this->infos as $Info){
			if($Info->getLangue()->getIso()==$iso){
				$val = $Info->getLabel();
			}
		}
		return $val;
	}
	public function isDefault(){
		return $this->is_default;
	}
	public function getTypeEntiteId(){
		return $this->typeEntiteId;
	}
	public function getValues(){
		return $this->values;
	}
	public function getValue($iso){
		$val = null;
		foreach ($this->values as $Value){
			if($Value->getLangue()->getIso() == $iso){
				$val = $Value;
			}
		}
		return $val;
	}
	public function getTypePropriete(){
		return $this->TypePropriete;
	}
	public function getListe(){
		return $this->Liste;
	}
	public function setDefault($bool){
		if($bool==1 || $bool == 0){
			$this->is_default = $bool;
		}else{
			throw new FieldFormatException($_SESSION['translator']->boolErr);
		}
	}
	public function setTypeEntiteId($typeEntiteId){
		$this->typeEntiteId = $typeEntiteId;
	}
	public function setTypepropriete($TypePropriete){
		if(is_a($TypePropriete, 'TypePropriete')){
			$this->TypePropriete = $TypePropriete;
		}else{
			throw new FieldFormatException($_SESSION['translator']->reqInstance." TypePropriete");
		}
	}
	public function setListe($Liste){
		if(is_a($Liste, 'Liste')){
			$this->Liste = $Liste;
		}
	}
	public function setInfos($infoTab){
		if(is_array($infoTab)){
			$bool = true;
			foreach ($infoTab as $info){
				if  (!is_a($info, 'ProprieteInfo')){
					$bool=false;
				}
			}
			if (!$bool){
				throw new FieldFormatException($_SESSION['translator']->listEx." ProprieteInfo");
			}else{
				$this->infos=$infoTab;
			}
		}else{
			throw new FieldFormatException($_SESSION['translator']->arrayErr);
		}
	}
	public function setValues($valueTab){
		if(is_array($valueTab)){
			$bool = true;
			foreach ($valueTab as $value){
				if  (!is_a($value, 'ProprieteValue')){
					$bool=false;
				}
			}
			if (!$bool){
				throw new FieldFormatException($_SESSION['translator']->listEx." ProprieteValue");
			}else{
				$this->values=$valueTab;
			}
		}else{
			throw new FieldFormatException($_SESSION['translator']->arrayErr);
		}
	}
}